#include "main.h"
#include "key_inpu.h"
#include "gd32f30x.h"

#if ENABLE_KEY_INPUT_TEST == 1



void key_input_config(void)
{
    //配置PA1外部中断
	rcu_periph_clock_enable(RCU_GPIOA);//GPIOA时钟使能
    gpio_init(GPIOA, GPIO_MODE_IPU, GPIO_OSPEED_50MHZ, GPIO_PIN_1);//PA1配置成上拉输入
	nvic_irq_enable(EXTI1_IRQn, 2U, 0U);//enable and set key EXTI interrupt to the lowest priority 
    gpio_exti_source_select(GPIO_PORT_SOURCE_GPIOA, GPIO_PIN_SOURCE_1);//connect key EXTI line to key GPIO pin
	exti_init(EXTI_1, EXTI_INTERRUPT, EXTI_TRIG_FALLING);//下降沿中断
	exti_interrupt_flag_clear(EXTI_1);//清中断标志
}

#endif //ENABLE_KEY_INPUT_TEST == 1